<%@page import="util.Configuration"%>
<%@page import="util.Utils"%>
<%@page import="persistence.DrupalHibernateManager"%>
<%@page import="java.util.List"%>
<%@page import="domain.RepresentationsNamesRecord"%>
<%@page import="persistence.Axdbv4HibernateManager"%>

<%@page import="java.util.Date"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Names Management - Statistics</title>

<style type="text/css" >@import url("themes/css/StatisticsStile.css"); </style>
</head>
<%  
	System.out.println("Avviata jsp(servlet) statistics.jsp");
	request.setCharacterEncoding("UTF-8");
	//System.out.println("DBSettings"+request.getSession().getAttribute("DBSettings"));
	if(request.getSession().getAttribute("DBSettings")==null){
		if(Configuration.getIstance().isReadDBConfigFileFailed()){
			//System.out.println("ATTENZIONE!File di configurazione del DataBase NON TROVATO!Verranno usati parametri standard: host="+Axdbv4HibernateManager.getHost()+" user="+Axdbv4HibernateManager.getUser()+"\n");
			
		}else{
		String[] settings= new String[3];
		settings[0]=Configuration.getIstance().getAxdbHost();
		settings[1]=Configuration.getIstance().getAxdbUser();
		settings[2]=Configuration.getIstance().getAxdbPassword();
		Axdbv4HibernateManager.setHost(settings[0]);
		Axdbv4HibernateManager.setUser(settings[1]);
		Axdbv4HibernateManager.setPassword(settings[2]);
		DrupalHibernateManager.setHost(settings[0]);
		DrupalHibernateManager.setUser(settings[1]);
		DrupalHibernateManager.setPassword(settings[2]);
		request.getSession().setAttribute("DBSettings", settings);
		}
	}

%>
<% Axdbv4HibernateManager dbManager=Axdbv4HibernateManager.getIstance();
		HashMap<String, Integer> hmap=(HashMap<String, Integer>) dbManager.getStatistics(); %>

<body>

<div id="page">

	<div id="header" style="text-align: center;">
		<h1>STATISTICHE</h1>	
	</div>
	
	<hr>
		<hr align=”left” size=”1″ width=”300″ color=”red” noshade>
	<div id="main">
		<%
		 int nomiTrovati=hmap.get("numberOfRecordsRepresentationName");
		int nomiBlackListati=hmap.get("numberOfBlackListed");
		int nomiSinonimi= hmap.get("numberOfSynonymous");
		float blackListedPercent=(float)nomiBlackListati/(float)nomiTrovati*100;
		float sinonimiPercent=(float)nomiSinonimi/(float)nomiTrovati*100;
		
		%>
		
		
		<div class="infoStatisticBlock">
		
		<div class="titoloDellaInfo">Root Object:</div>
		<%int objectElab=hmap.get("numberOfAnalyzedRootObjects");
		  int objectTotal=hmap.get("numberOfRootObjects");
		  float objectPercent=(float)objectElab/(float)objectTotal*100;
		%>
		<div class="infoStatisticSUBBlock">
		
		 <div class="testoDellaInfo">Oggetti Totali: </div><div class="infoGenerale"><%=objectTotal %> </div>
   		 </div>
   		 <div class="infoStatisticSUBBlock">
   		 <div class="testoDellaInfo">Oggetti Elaborati: </div><div class="infoImportante"><%=objectElab %> <div class="infoPercentualImportante">  (<%=objectPercent %>%)</div> </div>
		<div id="progressbar" >
      		<div style="width: <%=objectPercent %>%;"></div>
   		 </div>
   		
   		 </div>
   		 </div>
   		 
   		 <div class="infoStatisticBlock">
		<div class="titoloDellaInfo">Representation Name Table</div>
		
		<div class="infoStatisticSUBBlock">
		<div class="testoDellaInfo">Numero Nomi Totale Trovati</div> <div class="infoGenerale"> <%=nomiTrovati %> </div>
		</div>
		<div class="infoStatisticSUBBlock">
		<div class="testoDellaInfo">Numero Sinonimi Assegnati: </div> <div class="infoGenerale"><%=nomiSinonimi %> (<%=sinonimiPercent%> %) </div>
		<%-- <div id="progressbar">
      		<div style="width: <%=sinonimiPercent%>%;"></div>
   		 </div> --%>
		</div>
		<div class="infoStatisticSUBBlock">
		<div class="testoDellaInfo">Numero Nomi BlackListati: </div><div class="infoGenerale"><%=nomiBlackListati %>  (<%=blackListedPercent%> %) </div>
		<%-- <div id="progressbar">
      		<div style="width: <%=blackListedPercent%>%;"></div>
   		 </div> --%>

   		 </div>
		</div>
   		<%
		int eclapAssociations=hmap.get("numberOfEclapUserAssociation");
		int DBpediaAssociations=hmap.get("numberOfDBpediaAssociation");
		float eclapAssociationsPercent=(float)eclapAssociations/(float)(nomiTrovati-nomiBlackListati)*100;
		float DBpediaAssociationsPercent=(float)DBpediaAssociations/(float)(nomiTrovati-nomiBlackListati)*100;
		int eclapTotalAssociations=hmap.get("numberOfTotalEclapUserAssociation");
		int DBpediaTotalAssociations=hmap.get("numberOfTotalDBpediaAssociation");
		int eclapProcessed=hmap.get("numberOfRepresentationNameRecords_EclapExtraInfo_processed");
		int DBpediaProcessed=hmap.get("numberOfRepresentationNameRecords_DBpediaExtraInfo_processed");
		//int numberOfRepresentationNameRecords_extraInfo_processed=hmap.get("numberOfRepresentationNameRecords_extraInfo_processed");
		float eclapElabPercent=((float)eclapProcessed/(float)nomiTrovati)*100;
		float dbpediaElabPercent=((float)DBpediaProcessed/(float)nomiTrovati)*100;
		float eclapElabAssoPercent=((float)eclapAssociations/(float)eclapProcessed)*100;
		float DbpediaElabAssoPercent=((float)DBpediaAssociations/(float)DBpediaProcessed)*100;
		%> 
   		 
   		
		
	
		<div class="infoStatisticBlock">
		<div class="titoloDellaInfo">Statiche della ricerca di associazioni</div>
		 <div class="infoStatisticSUBBlock">
		 <div class="testoDellaInfo">Percentuale nomi elaborati per ricerca tra utenti Eclap: </div><div class="infoGenerale"><%=eclapElabPercent %>%</div>
		<div id="progressbar">
      		<div style="width: <%=eclapElabPercent %>%;"></div>
   		 </div>
   		 <div class="testoDellaInfo">Percentuale nomi elaborati per ricerca in DBpedia: </div><div class="infoGenerale"><%=dbpediaElabPercent %>%</div>
		<div id="progressbar">
      		<div style="width: <%=dbpediaElabPercent %>%;"></div>
   		 </div>
   		 </div>
   		 <div class="infoStatisticSUBBlock">
		<div class="testoDellaInfo">Percentuale di nomi, tra quelli processati, con almeno un utente Eclap associato: </div><div class="infoGenerale"><%=eclapElabAssoPercent %>%</div>
		<div id="progressbar">
      		<div style="width: <%=eclapElabAssoPercent %>%;"></div>
   		 </div>
   		
   		<div class="testoDellaInfo">Percentuale di nomi, tra quelli ricercati, con almeno un utente DBpedia associato:</div><div class="infoGenerale"><%=DbpediaElabAssoPercent %>%</div>
		<div id="progressbar">
      		<div style="width: <%=DbpediaElabAssoPercent %>%;"></div>
   		 </div>
   		 </div>
   		 </div>


<div class="infoStatisticBlock">
   				
		<div class="titoloDellaInfo">Associazioni tra Nomi e Persone</div>
		<div class="infoStatisticSUBBlock">
		<div class="testoDellaInfo">Numero di nomi con almeno un utente Eclap associato (sul totale dei nomi trovati): </div> <div class="infoGenerale"><%=eclapAssociations %> (<%=eclapAssociationsPercent %>%)</div>
		<div id="progressbar">
      		<div style="width: <%=eclapAssociationsPercent %>%;"></div>
   		 </div>
   		 </div>
   		 
   		 <div class="infoStatisticSUBBlock">
		<div class="testoDellaInfo">Numero di nomi con almeno un personaggio di DBpedia associato (sul totale dei nomi trovati): </div><div class="infoGenerale"><%=DBpediaAssociations %> (<%=DBpediaAssociationsPercent %>%)</div>
		<div id="progressbar">
      		<div style="width: <%=DBpediaAssociationsPercent %>%;"></div>
   		 </div>
 		</div>
 		 <div class="infoStatisticSUBBlock">
		<div class="testoDellaInfo">Numero totale di associazioni "Nome-Utente di Eclap": </div><div class="infoGenerale"><%=eclapTotalAssociations %> </div>
		</div>
		 <div class="infoStatisticSUBBlock">
		<div class="testoDellaInfo">Numero totale di associazioni "Nome-Link di DBpedia": </div><div class="infoGenerale"><%=DBpediaTotalAssociations %> </div>
		</div>
   		
   		</div>

		
				
		<%-- <h3>Optional Field Table</h3>
		<%int optionalFieldElab=hmap.get("numberOfRecordsAnalyzedOptionalField");
		  int optionalFieldTot=hmap.get("numberOfRecordsOptionalField");
		  float optionalFieldPercent=(float)optionalFieldElab/(float)optionalFieldTot*100;
			
		%>
		<label> &nbsp;&nbsp;&nbsp;&nbsp;<b>Record Elaborati: </b><%= optionalFieldElab%> (<%=optionalFieldPercent %>%) </label>
		<label> &nbsp;&nbsp;&nbsp;&nbsp;<b>Record Totali: </b><%=optionalFieldTot %> </label>
		<br> --%>
		</div>
		
		
	</div>



</body>
</html>